using Core;
using IglooCoder.Commons.WcfNhibernate;
using NHibernate;

namespace Infrastucture
{
    public class CashBankOutRepository : BaseNHibernateRepository<CashBankOut>
    {
        public CashBankOutRepository(ISessionStorage sessionStorage)
            : base(sessionStorage)
        {
        }


        public string GetMaxNumber(string code, string kodeAwal)
        {
            string res = string.Empty;
            var lenKode = kodeAwal.Length + 11 + code.Length;
            var query = Session.CreateSQLQuery("Select Max(NoVoucher) as Number from CashBankOut  where NoVoucher like'" + kodeAwal + "%' AND NoVoucher like'%" + code + "%'");
            var objRes = query.List()[0];
            if (objRes != null) res = objRes.ToString();
            return res;
        }
    }
}